package com.zmn.oms.services.impl.trace;

import com.zmn.oms.model.entity.trace.BaiduOrderTrace;
import com.zmn.oms.model.entity.trace.SogouOrderTrace;
import com.zmn.oms.model.entity.trace.ToutiaoOrderTrace;
import com.zmn.oms.persistence.interfaces.trace.ChanOrderTraceBaiduDao;
import com.zmn.oms.persistence.interfaces.trace.ChanOrderTraceSogouDao;
import com.zmn.oms.persistence.interfaces.trace.ChanOrderTraceToutiaoDao;
import com.zmn.oms.services.interfaces.trace.ChannelOrderTraceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * 渠道溯源数据保存接口实现.
 *
 * @author xiewenbing
 * @date 2021/07/29
 */
@Service
@Slf4j
public class ChannelOrderTraceServiceImpl implements ChannelOrderTraceService {

    @Resource
    private ChanOrderTraceBaiduDao chanOrderTraceBaiduDao;

    @Resource
    private ChanOrderTraceToutiaoDao chanOrderTraceToutiaoDao;

    @Resource
    private ChanOrderTraceSogouDao chanOrderTraceSogouDao;


    /**
     * 添加百度推广渠道订单溯源数据
     * @param baiduOrderTrace
     */
    @Override
    public void addBaiduOrderTrace(BaiduOrderTrace baiduOrderTrace) {

        if (Objects.isNull(baiduOrderTrace)) {
            return;
        }

        chanOrderTraceBaiduDao.insert(baiduOrderTrace);
    }

    /**
     * 添加今日头条渠道订单溯源数据
     * @param toutiaoOrderTrace
     */
    @Override
    public void addToutiaoOrderTrace(ToutiaoOrderTrace toutiaoOrderTrace) {

        if (Objects.isNull(toutiaoOrderTrace)) {
            return;
        }

        chanOrderTraceToutiaoDao.insert(toutiaoOrderTrace);
    }

    /**
     * 添加搜狗搜索渠道订单溯源数据
     * @param sogouOrderTrace
     */
    @Override
    public void addSogouOrderTrace(SogouOrderTrace sogouOrderTrace) {

        if (Objects.isNull(sogouOrderTrace)) {
            return;
        }

        chanOrderTraceSogouDao.insert(sogouOrderTrace);

    }
}
